<template>
  <div class="app-container">
    <el-form inline>
      <el-form-item>
        <el-input v-model="keyword" placeholder="治疗评估表名称" size="small" clearable />
      </el-form-item>
      <el-form-item>
        <el-button type="primary" size="small" @click="search">查询</el-button>
      </el-form-item>
      <el-form-item>
        <el-button size="small" @click="goBack">返回</el-button>
      </el-form-item>
    </el-form>
    <el-table :data="list" v-loading="loading">
      <el-table-column label="序号">
        <template slot-scope="scope">{{ scope.$index + 1 }}</template>
      </el-table-column>
      <el-table-column label="治疗评估表" prop="name" />
      <el-table-column label="操作">
        <template slot-scope="scope">
          <el-button v-if="scope.row.isEvaluate" type="text" @click="jumpPage(scope.row.editRoute, 0)">评估</el-button>
          <el-button v-if="!scope.row.isEvaluate || scope.row.hasEvaluate" type="text"
            @click="jumpPage(scope.row.detailRoute, 2)">详情</el-button>
        </template>
      </el-table-column>
    </el-table>
  </div>
</template>

<script>
import { listByReservationId } from '@/api/treatment/treatment.js'
const assessList = [
  // {
  //   name: '吞咽功能障碍评定',
  //   editRoute: 'SwallowEdit',
  //   detailRoute: 'SwallowView'
  // },
  // {
  //   name: '肺功能和日常生活评定表',
  //   editRoute: 'PulmonaryEdit',
  //   detailRoute: 'PulmonaryView'
  // },
  // {
  //   name: '周围性面神经炎治疗成绩评分表',
  //   editRoute: 'FacialNerveEdit',
  //   detailRoute: 'FacialNerveView'
  // },
  // {
  //   name: '初期康复评定记录表',
  //   editRoute: 'EarlyEdit',
  //   detailRoute: 'EarlyView'
  // },
  // {
  //   name: '中期康复评定记录表',
  //   editRoute: 'MidTermEdit',
  //   detailRoute: 'MidTermView'
  // },
  // {
  //   name: '出院前康复评定记录表',
  //   editRoute: 'DischargeEdit',
  //   detailRoute: 'DischargeView'
  // },
  // {
  //   name: '偏瘫运动功能评定表',
  //   editRoute: 'HemiplegiaEdit',
  //   detailRoute: 'HemiplegiaView'
  // },
  // {
  //   name: '神经损伤功能评定表',
  //   editRoute: 'NerveInjuryEdit',
  //   detailRoute: 'NerveInjuryView'
  // },
  // {
  //   name: '神经康复综合评定表',
  //   editRoute: 'NeurorehabilitationEdit',
  //   detailRoute: 'NeurorehabilitationView'
  // },
  // {
  //   name: '感知能力-耳聋分级',
  //   editRoute: 'DeafGradeEdit',
  //   detailRoute: 'DeafGradeView'
  // },
  // {
  //   name: '感知能力-程度评估',
  //   editRoute: 'DegreeEdit',
  //   detailRoute: 'DegreeView'
  // },
  // {
  //   name: '运动能力',
  //   editRoute: 'MotionEdit',
  //   detailRoute: 'MotionView'
  // },
  {
    name: "针灸医疗记录单",
    editRoute: 'acupunctureEdit',
    detailRoute: 'acupunctureView'
  },
  {
    name: "康复治疗记录单",
    editRoute: 'rehabRecordEdit',
    detailRoute: 'rehabRecordView'
  },
  {
    name: "临床康复介入医疗记录单",
    editRoute: 'clinicalRecordEdit',
    detailRoute: 'clinicalRecordView'
  },
  {
    name: "滨江高压氧治疗的心理护理及安全告知书",
    editRoute: 'hyperbaricNoticeBJEdit',
    detailRoute: 'hyperbaricNoticeBJView'
  },
  {
    name: "高压氧治疗的心理护理及安全告知书",
    editRoute: 'hyperbaricNoticeEdit',
    detailRoute: 'hyperbaricNoticeView'
  },
  {
    name: "舱内治疗评估",
    editRoute: 'chamberEvalEdit',
    detailRoute: 'chamberEvalView'
  },
  // {
  //   name: "MMSE简易智能精神状态检查量表",
  //   editRoute: 'mmseScaleEdit',
  //   detailRoute: 'mmseScaleView'
  // },
  // {
  //   name: "焦虑自评量表(SAS)",
  //   editRoute: 'sasScaleEdit',
  //   detailRoute: 'sasScaleView'
  // },
  // {
  //   name: "抑郁自评量表",
  //   editRoute: 'sdScaleEdit',
  //   detailRoute: 'sdScaleView'
  // },
  // {
  //   name: "阿森斯失眠量表",
  //   editRoute: 'aisaScaleEdit',
  //   detailRoute: 'aisaScaleView'
  // },
  // {
  //   name: "9条目患者健康问卷(PHQ-9)",
  //   editRoute: 'phqQuestEdit',
  //   detailRoute: 'phqQuestView'
  // },
  // {
  //   name: "GAD-7自评量表",
  //   editRoute: 'gadScaleEdit',
  //   detailRoute: 'gadScaleView'
  // },
  // {
  //   name: "症状自评量表(SCL-90)",
  //   editRoute: 'sclScaleEdit',
  //   detailRoute: 'sclScaleView'
  // },
  // {
  //   name: "SCL-90测评纸",
  //   editRoute: 'sclPaperEdit',
  //   detailRoute: 'sclPaperView'
  // },
  // {
  //   name: "SCL-90症状自评量表-简介",
  //   editRoute: 'sclCheckIntroEdit',
  //   detailRoute: 'sclCheckIntroView'
  // },
  // {
  //   name: "症状自评量表(SCL-90)使用说明",
  //   editRoute: 'sclinventoryEdit',
  //   detailRoute: 'sclinventoryView'
  // },
  // {
  //   name: "鼻炎熏蒸告知书",
  //   editRoute: 'rhiNoticeEdit',
  //   detailRoute: 'rhiNoticeView'
  // },
  // {
  //   name: "面部熏蒸告知书",
  //   editRoute: 'facialNoticeEdit',
  //   detailRoute: 'facialNoticeView'
  // },
  // {
  //   name: "眼部熏蒸告知书",
  //   editRoute: 'ocularFumigNoticeEdit',
  //   detailRoute: 'ocularFumigNoticeView'
  // },
  // {
  //   name: "熏蒸治疗单",
  //   editRoute: 'fumigRecEdit',
  //   detailRoute: 'fumigRecView'
  // },
  // {
  //   name: "督脉熏蒸治疗单",
  //   editRoute: 'duMeriRecEdit',
  //   detailRoute: 'duMeriRecView'
  // },
  // {
  //   name: "督脉熏蒸治疗告知书",
  //   editRoute: 'duMeriNoticeEdit',
  //   detailRoute: 'duMeriNoticeView'
  // },
  // {
  //   name: "腹直肌分离修复告知书",
  //   editRoute: 'rectusNoticeEdit',
  //   detailRoute: 'rectusNoticeView'
  // },
  // {
  //   name: "腹直肌治疗记录单",
  //   editRoute: 'rectusRecEdit',
  //   detailRoute: 'rectusRecView'
  // },
  // {
  //   name: "盆底检查报告单",
  //   editRoute: 'pelvicExaRepEdit',
  //   detailRoute: 'pelvicExaRepView'
  // },
  // {
  //   name: "盆底康复治疗单",
  //   editRoute: 'pelvicRehabRecEdit',
  //   detailRoute: 'pelvicRehabRecView'
  // },
  // {
  //   name: "盆底康复治疗告知书",
  //   editRoute: 'pelvicRehabNoticeEdit',
  //   detailRoute: 'pelvicRehabNoticeView'
  // }
]

export default {
  name: 'Assess',
  data() {
    return {
      list: [],
      keyword: '',
      id: 1,
      loading: true
    }
  },
  computed: {
    addRoutes() {
      if (this.$store.getters && this.$store.getters.addRouters) {
        return this.$store.getters.addRouters
      } else {
        return []
      }
    }
  },
  mounted() {
    this.id = this.$route.query.id
    this.getListByReservationId()
  },
  methods: {
    getListByReservationId() {
      this.loading = true;
      listByReservationId({
        reservationId: this.id,
        estimateName: this.keyword
      }).then(res => {
        this.loading = false;
        this.list = res.content.map(item => {
          const assess = assessList.find(assess => assess.name === item.estimateName)
          return {
            ...assess,
            isEvaluate: item.isEvaluate,
            hasEvaluate: item.hasEvaluate
          }
        })
      })
    },
    hasRoute(list, routeName) {
      return list.some(item => {
        if (item.name === routeName) {
          return true
        } else {
          if (item.children && item.children.length) {
            return this.hasRoute(item.children, routeName)
          } else {
            return false
          }
        }
      })
    },
    search() {
      this.getListByReservationId()
    },
    jumpPage(routeName, type) {
      this.$router.push({
        name: routeName,
        query: {
          id: this.id,
          adviceId: this.$route.query.adviceId,
          type,
          source: 3
        }
      })
    },
    goBack() {
      this.$store.dispatch('tagsView/delView', this.$route)
      this.$router.back()
    }
  }
}
</script>

<style lang="scss" scoped></style>
